package com.wbao.dianniu.update;

import java.util.LinkedList;

import com.wbao.dianniu.data.RecruitAddData;
import com.wbao.dianniu.data.RecruitListData;

public class RecruitListChangeManager {
	private static LinkedList<RecruitChangedListener> mListener;
	private static RecruitListChangeManager instance;

	public static RecruitListChangeManager getInstance() {
		if (null == instance) {
			mListener = new LinkedList<RecruitChangedListener>();
			instance = new RecruitListChangeManager();
		}
		return instance;
	}

	private RecruitListChangeManager() {
	}

	public interface RecruitChangedListener {
		public void recruitAddChanged(RecruitListData data);

		public void recruitRemoveChanged(int position);

		public void recruitModifyChanged(int id, RecruitAddData data);
	}

	public void addRecruitChangeListener(RecruitChangedListener listener) {
		mListener.add(listener);
	}

	public void removeRecruitChangeListener(RecruitChangedListener listener) {
		mListener.remove(listener);
	}

	public void notifyAdd(RecruitListData data) {
		for (int i = 0; i < mListener.size(); i++) {
			mListener.get(i).recruitAddChanged(data);
		}
	}

	public void notifyRemove(int recruitId) {
		for (int i = 0; i < mListener.size(); i++) {
			mListener.get(i).recruitRemoveChanged(recruitId);
		}
	}

	public void notifyModify(int recruitId, RecruitAddData data) {
		for (int i = 0; i < mListener.size(); i++) {
			mListener.get(i).recruitModifyChanged(recruitId, data);
		}
	}
}
